<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt" %>

<!DOCTYPE html>
<html>
<head>
  <title>应急预案图纸</title>

  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!-- 引入bootstrap -->
  <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
  <link rel="stylesheet" type="text/css" href="/css/page.css">
  <!-- 引入JQuery  bootstrap.js-->
  <script src="/js/jquery-3.2.1.min.js"></script>
  <script src="/js/bootstrap.min.js"></script>
  <script src="/js/jquery.easyui.min.js"></script>
  <script type="text/javascript" src="/js/page.js"></script>
<%--  <script src="https://www.jq22.com/js/jquery.qrcode.min.js"></script>--%>
<%--  <script src="https://www.jq22.com/js/pace.min.js"></script>--%>
  <%--<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">--%>

</head>
<body>
<div id="content2" class="col-md-12" data-example-id="bordered-table">
  <h1 id="title1" class="text-center">应急预案图纸 </h1>
  <form class="form-horizontal" role="form"  id="from1" method="post">
    <h4 id="drawing"><a >发布图纸</a></h4>
    <table class="table table-bordered">
      <thead >
      <tr>
        <th>ID</th>
        <th>标题</th>
        <th>事故类型</th>
        <th>图纸日期</th>
        <th>上传日期</th>
        <th>上传人</th>
        <th>地点</th>
        <th>备注</th>
        <th>操作</th>
      </tr>
      </thead>
      <tbody id="table">

      </tbody>
    </table>
    <div class="pageTest"></div>
    <div class="col-sm-offset-2 col-sm-10">

    </div>
  </form>
</div>
<script>

</script>

</body>
<script type="text/javascript">

  var pages=2;
  var total=0;
  var page=1;
  var  limit=2;
  // 时间戳转时间
  function transformTime(timestamp = +new Date()) {
    if (timestamp) {
      var time = new Date(timestamp);
      var y = time.getFullYear(); //getFullYear方法以四位数字返回年份
      var M = time.getMonth() + 1; // getMonth方法从 Date 对象返回月份 (0 ~ 11)，返回结果需要手动加一
      var d = time.getDate(); // getDate方法从 Date 对象返回一个月中的某一天 (1 ~ 31)
      var h = time.getHours(); // getHours方法返回 Date 对象的小时 (0 ~ 23)
      var m = time.getMinutes(); // getMinutes方法返回 Date 对象的分钟 (0 ~ 59)
      var s = time.getSeconds(); // getSeconds方法返回 Date 对象的秒数 (0 ~ 59)
      return y + '-' + M + '-' + d + ' ' + h + ':' + m + ':' + s;
    } else {
      return '';
    }
  }

  $("#drawing").click(function () {
    $("#content3").empty()
    $("#content4").empty()
    $("#content4").load("/ReservePlandrawing/filesUpload")
  })

  function  pageRequest( page, limit){
    $.ajax({
      url: "/ReservePlandrawing/selectReservePlandrawingList/"+page+"/"+limit,
      type: "GET",
      dataType: "JSON",
      success:function (data) {
         data2=data.data.list;
        pages=data.data.pages;
        total=data.data.total;
        page=page;
        limit=limit;
        for(var i=0;i<data.data.list.length;i++){
          $("#table").append("<tr class='pagetr'>" +
                  "<td>"+data.data.list[i].reserve_plan_id+"</td>" +
                  "<td>"+data.data.list[i].reserve_plan_title+"</td>" +
                  "<td>"+data.data.list[i].accident_type+"</td>"+
          "<td>"+data.data.list[i].drawing_time+"</td>"+
          "<td>"+data.data.list[i].drawing_upload_time+"</td>"+
          "<td>"+data.data.list[i].drawing_upload_user_name+"</td>"+
                  "<td>"+data.data.list[i].plan_id+"</td>"+
                  "<td>"+data.data.list[i].remarks+"</td>"+
                  /*"<td>"+data.data.list[i].drawing_upload_filepath+"</td>"+*/
                  "<td>"+"<a href='pdf'><input"+" type='button'" +"id=''"+" value="+"预览" +" /></a>"+"<input"+" type='button'" +"id='"+data.data.list[i].reserve_plan_id+"'"+" value="+"删除" +" /></td>"+
                  "</tr>");
          var  id=data.data.list[i].reserve_plan_id
          $("#"+id).click(function () {

            var msg = "您真的确定要删除吗？！";
            if (confirm(msg)==true) {
              $.ajax({
                url: '/ReservePlandrawing/DeleteReservePlandrawing/'+id,
                type: 'delete',
                success: function () {
                  alert("删除成功")
                  window.location.href = "drawing";

                },
                error: function () {
                  alert("保存失败")
                }
              })
            }else {

            }
          })
        }



      }
    })

  }
/*  click="+alert(data.data.list[i].reserve_plan_id)*/

 function changlimit(){//修改数据条数
    $('.pageTest').setLength(pages);
   pageRequest(page,limit);
  }




  $(function () {
    pageRequest(1,5);

  })


  $('.pageTest').page({
    leng: 2, //分页总数
    activeClass: 'activP', //active 类样式定义
    clickBack:function(page){
      $(".pagetr").empty();
      $('.pageTest').setLength(pages);
      pageRequest(page,limit);
    }
  })
  // $('.pageTest').setLength(10)
</script>
</html>